package bookstore.model;

import javax.persistence.Entity;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Objects;
import java.util.Set;

@Entity
public class Order {
    private Long orderid;
    private Long userid;
    private Timestamp time = new Timestamp(new Date().getTime());
    private Set<OrderItem> items;
    private String name;
    private String tel;
    private String addr;

    public Long getOrderid() {
        return orderid;
    }

    public void setOrderid(Long orderid) {
        this.orderid = orderid;
    }

    public Long getUserid() {
        return userid;
    }

    public void setUserid(Long userid) {
        this.userid = userid;
    }

    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Order order = (Order) o;
        return Objects.equals(orderid, order.orderid) &&
                Objects.equals(userid, order.userid) &&
                Objects.equals(time, order.time) && Objects.equals(name, order.name) &&
                Objects.equals(tel, order.tel) &&
                Objects.equals(addr, order.addr);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderid, userid, time);
    }

    public Set<OrderItem> getItems() {
        return items;
    }

    public void setItems(Set<OrderItem> items) {
        this.items = items;
    }

}
